#ifndef ACTIONCONSUMER_H
#define ACTIONCONSUMER_H

#include "IplaybackAction.h"
#include <memory>
#include <string>
#include <thread>
#include <vector>

std::unique_ptr<IplaybackAction> createCanAction(const std::string& sigName, const int& value);
std::unique_ptr<IplaybackAction> createSleepAction(const uint32_t& value);

class ActionConsumer
{
public:
    ActionConsumer();
    ~ActionConsumer();

    void pushBackAction(std::unique_ptr<IplaybackAction>&& action);
    void parseJsonAsAction(const char* path);
    void writeActionToJson();
    void playOnce();
    void playLoop();
    void stopPlay();
    void clearActions();
    void startRecord();
    void recording(const char* sigName, int value);
    void stopRecord();

    static std::unique_ptr<ActionConsumer>& getInstance();

private:
    void playAction();

    bool                                            isRunning;
    std::unique_ptr<std::thread>                    itsActionThread;
    std::vector<std::unique_ptr<IplaybackAction>>   itsActions;

    static std::unique_ptr<ActionConsumer> actionConsumerInstance;
};


#endif
